From: Florian Müllner Date: Fri, 31 Oct 2025 17:14:14 +0000 (+0100) Subject: js: Use one-shot idle/timeout functions X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~39^2~1^2~26 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=046cc0e647262332243f0b0001004cd6345cfba8;p=gnome-shell.git js: Use one-shot idle/timeout functions gjs now provides overrides for GLib's one-shot idle/timeout functions, so use them to save a bit of code and clearly indicate that a callback is only invoked once. Part-of: --- diff --git a/js/dbusServices/dbusService.js b/js/dbusServices/dbusService.js index 85ed0d9ad..37677f4a5 100644 --- a/js/dbusServices/dbusService.js +++ b/js/dbusServices/dbusService.js @@ -120,13 +120,11 @@ export class ServiceImplementation { if (this._shutdownTimeoutId) GLib.source_remove(this._shutdownTimeoutId); - this._shutdownTimeoutId = GLib.timeout_add_seconds( + this._shutdownTimeoutId = GLib.timeout_add_seconds_once( GLib.PRIORITY_DEFAULT, IDLE_SHUTDOWN_TIME, () => { this._shutdownTimeoutId = 0; this._maybeShutdown(); - - return GLib.SOURCE_REMOVE; }); } diff --git a/js/dbusServices/extensions/extensionPrefsDialog.js b/js/dbusServices/extensions/extensionPrefsDialog.js index fbd17bd52..24c32075d 100644 --- a/js/dbusServices/extensions/extensionPrefsDialog.js +++ b/js/dbusServices/extensions/extensionPrefsDialog.js @@ -52,10 +52,9 @@ export class ExtensionPrefsDialog extends Adw.PreferencesWindow { set_titlebar() { // intercept fatal libadwaita error, show error page instead - GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { this._showErrorPage( new Error('set_titlebar() is not supported for Adw.Window')); - return GLib.SOURCE_REMOVE; }); } diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js index 4441834f2..70b68e304 100644 --- a/js/gdm/loginDialog.js +++ b/js/gdm/loginDialog.js @@ -904,7 +904,7 @@ export const LoginDialog = GObject.registerClass({ } }); } else { - const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._loadUserList.bind(this)); + const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, this._loadUserList.bind(this)); GLib.Source.set_name_by_id(id, '[gnome-shell] _loadUserList'); } } @@ -1229,11 +1229,10 @@ export const LoginDialog = GObject.registerClass({ } }, conflictingSessionDialog); - const closeDialogTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, _CONFLICTING_SESSION_DIALOG_TIMEOUT, () => { + const closeDialogTimeoutId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, _CONFLICTING_SESSION_DIALOG_TIMEOUT, () => { this._notifyConflictingSessionDialogClosed(); conflictingSessionDialog.close(); this._authPrompt.reset(); - return GLib.SOURCE_REMOVE; }); conflictingSessionDialog.connect('closed', () => { @@ -1321,11 +1320,10 @@ export const LoginDialog = GObject.registerClass({ _blockTimedLoginUntilIdle() { const hold = new Batch.Hold(); - this._timedLoginIdleTimeOutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, _TIMED_LOGIN_IDLE_THRESHOLD, + this._timedLoginIdleTimeOutId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, _TIMED_LOGIN_IDLE_THRESHOLD, () => { this._timedLoginIdleTimeOutId = 0; hold.release(); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._timedLoginIdleTimeOutId, '[gnome-shell] this._timedLoginIdleTimeOutId'); return hold; @@ -1509,7 +1507,7 @@ export const LoginDialog = GObject.registerClass({ _loadUserList() { if (this._userListLoaded) - return GLib.SOURCE_REMOVE; + return; this._userListLoaded = true; @@ -1536,8 +1534,6 @@ export const LoginDialog = GObject.registerClass({ this._userList.addUser(user); this._updateDisableUserList(); }, this); - - return GLib.SOURCE_REMOVE; } activate() { diff --git a/js/gdm/util.js b/js/gdm/util.js index e9262b138..f762b79ec 100644 --- a/js/gdm/util.js +++ b/js/gdm/util.js @@ -291,7 +291,7 @@ export class ShellUserVerifier extends Signals.EventEmitter { delete this._currentMessageExtraInterval; this.emit('show-message', message.serviceName, message.text, message.type); - this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, + this._messageQueueTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, message.interval + (this._currentMessageExtraInterval | 0), () => { this._messageQueueTimeoutId = 0; @@ -301,8 +301,6 @@ export class ShellUserVerifier extends Signals.EventEmitter { } else { this.finishMessageQueue(); } - - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._messageQueueTimeoutId, '[gnome-shell] this._queueMessageTimeout'); } @@ -765,12 +763,11 @@ export class ShellUserVerifier extends Signals.EventEmitter { GLib.source_remove(this._fingerprintFailedId); const cancellable = this._cancellable; - this._fingerprintFailedId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, + this._fingerprintFailedId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, FINGERPRINT_ERROR_TIMEOUT_WAIT, () => { this._fingerprintFailedId = 0; if (!cancellable.is_cancelled()) this._verificationFailed(serviceName, false); - return GLib.SOURCE_REMOVE; }); } } diff --git a/js/misc/breakManager.js b/js/misc/breakManager.js index 18ebdf0a2..a72b9c109 100644 --- a/js/misc/breakManager.js +++ b/js/misc/breakManager.js @@ -805,7 +805,7 @@ class BreakDispatcher extends GObject.Object { if (this._countdownTimerId !== 0) GLib.source_remove(this._countdownTimerId); - this._countdownTimerId = GLib.timeout_add_seconds( + this._countdownTimerId = GLib.timeout_add_seconds_once( GLib.PRIORITY_DEFAULT, countdownStart, () => { if (this._countdownOsd == null) { @@ -814,7 +814,6 @@ class BreakDispatcher extends GObject.Object { () => (this._countdownOsd = null)); } this._countdownTimerId = 0; - return GLib.SOURCE_REMOVE; }); } @@ -1035,11 +1034,10 @@ class BreakNotificationSource extends GObject.Object { console.debug(`BreakNotificationSource: Scheduling notification state update in ${timeoutSeconds}s`); - this._timerId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, timeoutSeconds, () => { + this._timerId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, timeoutSeconds, () => { this._timerId = 0; console.debug('BreakNotificationSource: Scheduled notification state update'); this._updateState(); - return GLib.SOURCE_REMOVE; }); } diff --git a/js/misc/ibusManager.js b/js/misc/ibusManager.js index a9178805f..d9995b81a 100644 --- a/js/misc/ibusManager.js +++ b/js/misc/ibusManager.js @@ -329,7 +329,7 @@ class IBusManager extends Signals.EventEmitter { } this._preloadEnginesId = - GLib.timeout_add_seconds( + GLib.timeout_add_seconds_once( GLib.PRIORITY_DEFAULT, this._PRELOAD_ENGINES_DELAY_TIME, () => { @@ -339,7 +339,6 @@ class IBusManager extends Signals.EventEmitter { this._cancellable, null); this._preloadEnginesId = 0; - return GLib.SOURCE_REMOVE; }); } diff --git a/js/misc/inputMethod.js b/js/misc/inputMethod.js index f15eb2e39..f0c39e77b 100644 --- a/js/misc/inputMethod.js +++ b/js/misc/inputMethod.js @@ -219,10 +219,9 @@ export const InputMethod = GObject.registerClass({ this._preeditStr = null; } - this._hidePanelId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, HIDE_PANEL_TIME, () => { + this._hidePanelId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, HIDE_PANEL_TIME, () => { this.set_input_panel_state(Clutter.InputPanelState.OFF); this._hidePanelId = 0; - return GLib.SOURCE_REMOVE; }); } diff --git a/js/misc/timeLimitsManager.js b/js/misc/timeLimitsManager.js index abaf3ba24..f980477bc 100644 --- a/js/misc/timeLimitsManager.js +++ b/js/misc/timeLimitsManager.js @@ -1336,11 +1336,10 @@ class TimeLimitsNotificationSource extends GObject.Object { console.debug(`TimeLimitsNotificationSource: Scheduling notification state update in ${timeoutSeconds}s`); - this._timerId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, timeoutSeconds, () => { + this._timerId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, timeoutSeconds, () => { this._timerId = 0; console.debug('TimeLimitsNotificationSource: Scheduled notification state update'); this._updateState(); - return GLib.SOURCE_REMOVE; }); } diff --git a/js/portalHelper/main.js b/js/portalHelper/main.js index a3a802217..7004a3279 100644 --- a/js/portalHelper/main.js +++ b/js/portalHelper/main.js @@ -271,10 +271,9 @@ class PortalWindow extends Gtk.ApplicationWindow { const seconds = (CONNECTIVITY_RECHECK_RATELIMIT_TIMEOUT - timeSinceLastRecheck) / GLib.USEC_PER_SEC; - this._recheckTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, seconds, () => { + this._recheckTimeoutId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, seconds, () => { this._statusChangedCallback(PortalHelperResult.RECHECK); this._recheckTimeoutId = 0; - return GLib.SOURCE_REMOVE; }); } } diff --git a/js/ui/altTab.js b/js/ui/altTab.js index 91020e6d3..1a6c70503 100644 --- a/js/ui/altTab.js +++ b/js/ui/altTab.js @@ -349,7 +349,7 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup { this._thumbnails.highlight(window, forceAppFocus); } else if (this._items[this._selectedIndex].cachedWindows.length > 1 && !forceAppFocus) { - this._thumbnailTimeoutId = GLib.timeout_add( + this._thumbnailTimeoutId = GLib.timeout_add_once( GLib.PRIORITY_DEFAULT, THUMBNAIL_POPUP_TIME, this._timeoutPopupThumbnails.bind(this)); @@ -362,7 +362,6 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup { this._createThumbnails(); this._thumbnailTimeoutId = 0; this._thumbnailsFocused = false; - return GLib.SOURCE_REMOVE; } _destroyThumbnails() { @@ -826,14 +825,13 @@ class AppSwitcher extends SwitcherPopup.SwitcherList { if (this._altTabPopup.thumbnailsVisible) { this._delayedHighlighted = index; - this._mouseTimeOutId = GLib.timeout_add( + this._mouseTimeOutId = GLib.timeout_add_once( GLib.PRIORITY_DEFAULT, APP_ICON_HOVER_TIMEOUT, () => { this._enterItem(index); this._delayedHighlighted = -1; this._mouseTimeOutId = 0; - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._mouseTimeOutId, '[gnome-shell] this._enterItem'); } else { diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 5a2963486..a1de2a87d 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -691,11 +691,10 @@ var BaseAppView = GObject.registerClass({ this.goToPage(nextPage); this._canScroll = false; - this._scrollTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, + this._scrollTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, SCROLL_TIMEOUT_TIME, () => { this._canScroll = true; this._scrollTimeoutId = 0; - return GLib.SOURCE_REMOVE; }); return Clutter.EVENT_STOP; @@ -797,12 +796,11 @@ var BaseAppView = GObject.registerClass({ position, source, destroyId: source.connect('destroy', () => this._removeDelayedMove()), - timeoutId: GLib.timeout_add(GLib.PRIORITY_DEFAULT, + timeoutId: GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, DELAYED_MOVE_TIMEOUT, () => { this._moveItem(source, page, position); this._delayedMoveData.timeoutId = 0; this._removeDelayedMove(); - return GLib.SOURCE_REMOVE; }), }; } @@ -909,14 +907,13 @@ var BaseAppView = GObject.registerClass({ const {targetActor} = dragEvent; this._dragPageSwitchInitialTimeoutId = - GLib.timeout_add(GLib.PRIORITY_DEFAULT, DRAG_PAGE_SWITCH_INITIAL_TIMEOUT, () => { + GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, DRAG_PAGE_SWITCH_INITIAL_TIMEOUT, () => { const direction = targetActor === this._prevPageIndicator ? -1 : 1; this.goToPage(this._grid.currentPage + direction); this._setupDragPageSwitchRepeat(direction); delete this._dragPageSwitchInitialTimeoutId; - return GLib.SOURCE_REMOVE; }); } @@ -2815,10 +2812,9 @@ export const AppFolderDialog = GObject.registerClass({ return; this._popdownTimeoutId = - GLib.timeout_add(GLib.PRIORITY_DEFAULT, POPDOWN_DIALOG_TIMEOUT, () => { + GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, POPDOWN_DIALOG_TIMEOUT, () => { this._popdownTimeoutId = 0; this.popdown(); - return GLib.SOURCE_REMOVE; }); } @@ -3115,11 +3111,10 @@ export const AppIcon = GObject.registerClass({ return; this._folderPreviewId = - GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => { + GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 500, () => { this.add_style_pseudo_class('drop'); this._showFolderPreview(); this._folderPreviewId = 0; - return GLib.SOURCE_REMOVE; }); } else { if (this._folderPreviewId > 0) { diff --git a/js/ui/background.js b/js/ui/background.js index d5fdc9bc4..09edeb1be 100644 --- a/js/ui/background.js +++ b/js/ui/background.js @@ -177,9 +177,8 @@ class BackgroundCache extends Signals.EventEmitter { let animation = this._animations[params.settingsSchema]; if (animation && _fileEqual0(animation.file, params.file)) { if (params.onLoaded) { - const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { params.onLoaded(this._animations[params.settingsSchema]); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded'); } @@ -192,9 +191,8 @@ class BackgroundCache extends Signals.EventEmitter { this._animations[params.settingsSchema] = animation; if (params.onLoaded) { - const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { params.onLoaded(this._animations[params.settingsSchema]); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded'); } @@ -313,10 +311,9 @@ const Background = GObject.registerClass({ if (this._changedIdleId) return; - this._changedIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + this._changedIdleId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { this._changedIdleId = 0; this.emit('bg-changed'); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._changedIdleId, '[gnome-shell] Background._emitChangedSignal'); @@ -343,9 +340,8 @@ const Background = GObject.registerClass({ if (this._cancellable?.is_cancelled()) return; - const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { this.emit('loaded'); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(id, '[gnome-shell] Background._setLoaded Idle'); } @@ -449,12 +445,11 @@ const Background = GObject.registerClass({ if (interval > GLib.MAXUINT32) return; - this._updateAnimationTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, + this._updateAnimationTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, interval, () => { this._updateAnimationTimeoutId = 0; this._updateAnimation(); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._updateAnimationTimeoutId, '[gnome-shell] this._updateAnimation'); } @@ -544,9 +539,8 @@ export const SystemBackground = GObject.registerClass({ }); this.content.background = _systemBackground; - const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { this.emit('loaded'); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(id, '[gnome-shell] SystemBackground.loaded'); } @@ -818,9 +812,8 @@ export class BackgroundManager extends Signals.EventEmitter { let loadedSignalId; if (background.isLoaded) { - GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { this.emit('loaded'); - return GLib.SOURCE_REMOVE; }); } else { loadedSignalId = background.connect('loaded', () => { diff --git a/js/ui/components/automountManager.js b/js/ui/components/automountManager.js index ed895b536..5ea1e2e12 100644 --- a/js/ui/components/automountManager.js +++ b/js/ui/components/automountManager.js @@ -36,7 +36,7 @@ class AutomountManager { 'drive-disconnected', this._onDriveDisconnected.bind(this), 'drive-eject-button', this._onDriveEjectButton.bind(this), this); - this._mountAllId = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._startupMountAll.bind(this)); + this._mountAllId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, this._startupMountAll.bind(this)); GLib.Source.set_name_by_id(this._mountAllId, '[gnome-shell] this._startupMountAll'); } @@ -68,7 +68,6 @@ class AutomountManager { }); this._mountAllId = 0; - return GLib.SOURCE_REMOVE; } _onDriveConnected() { @@ -244,10 +243,9 @@ class AutomountManager { } _allowAutorunExpire(volume) { - const id = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, AUTORUN_EXPIRE_TIMEOUT_SECS, () => { + const id = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, AUTORUN_EXPIRE_TIMEOUT_SECS, () => { volume.allowAutorun = false; delete volume._allowAutorunExpireId; - return GLib.SOURCE_REMOVE; }); volume._allowAutorunExpireId = id; GLib.Source.set_name_by_id(id, '[gnome-shell] volume.allowAutorun'); diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js index c1566c263..68ee8dbb3 100644 --- a/js/ui/components/polkitAgent.js +++ b/js/ui/components/polkitAgent.js @@ -334,17 +334,15 @@ const AuthenticationDialog = GObject.registerClass({ this._sessionRequestTimeoutId = 0; if (this.state !== ModalDialog.State.OPENED) - return GLib.SOURCE_REMOVE; + return; this._passwordEntry.hide(); this._cancelButton.grab_key_focus(); this._okButton.reactive = false; - - return GLib.SOURCE_REMOVE; }; if (delay) { - this._sessionRequestTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, delay, resetDialog); + this._sessionRequestTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, delay, resetDialog); GLib.Source.set_name_by_id(this._sessionRequestTimeoutId, '[gnome-shell] this._sessionRequestTimeoutId'); } else { resetDialog(); diff --git a/js/ui/dash.js b/js/ui/dash.js index d3a3080f0..1df9414b4 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -546,12 +546,11 @@ export const Dash = GObject.registerClass({ if (shouldShow) { if (this._showLabelTimeoutId === 0) { const timeout = this._labelShowing ? 0 : DASH_ITEM_HOVER_TIMEOUT; - this._showLabelTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, timeout, + this._showLabelTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, timeout, () => { this._labelShowing = true; item.showLabel(); this._showLabelTimeoutId = 0; - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._showLabelTimeoutId, '[gnome-shell] item.showLabel'); if (this._resetHoverTimeoutId > 0) { @@ -565,11 +564,10 @@ export const Dash = GObject.registerClass({ this._showLabelTimeoutId = 0; item.hideLabel(); if (this._labelShowing) { - this._resetHoverTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, DASH_ITEM_HOVER_TIMEOUT, + this._resetHoverTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, DASH_ITEM_HOVER_TIMEOUT, () => { this._labelShowing = false; this._resetHoverTimeoutId = 0; - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._resetHoverTimeoutId, '[gnome-shell] this._labelShowing'); } diff --git a/js/ui/dnd.js b/js/ui/dnd.js index d769d1845..071dc1c0d 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -333,7 +333,7 @@ class _Draggable extends Signals.EventEmitter { if (result !== DragMotionResult.CONTINUE) { this._updateCursor(DRAG_CURSOR_MAP[result]); dragEvent.targetActor.disconnect(targetActorDestroyHandlerId); - return GLib.SOURCE_REMOVE; + return; } } } @@ -353,20 +353,19 @@ class _Draggable extends Signals.EventEmitter { 0); if (result !== DragMotionResult.CONTINUE) { this._updateCursor(DRAG_CURSOR_MAP[result]); - return GLib.SOURCE_REMOVE; + return; } } target = target.get_parent(); } this._updateCursor(Clutter.CursorType.NO_DROP); - return GLib.SOURCE_REMOVE; } _queueUpdateDragHover() { if (this._updateHoverId) return; - this._updateHoverId = GLib.idle_add(GLib.PRIORITY_DEFAULT, + this._updateHoverId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, this._updateDragHover.bind(this)); GLib.Source.set_name_by_id(this._updateHoverId, '[gnome-shell] this._updateDragHover'); } diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index 1dc94b40b..8a10c5c5b 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -65,11 +65,10 @@ export class ExtensionManager extends Signals.EventEmitter { const shutdownId = global.connect('shutdown', () => disableFile.delete(null)); - GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 60, () => { + GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, 60, () => { global.disconnect(shutdownId); disableFile.delete(null); - return GLib.SOURCE_REMOVE; }); this._installExtensionUpdates(); diff --git a/js/ui/init.js b/js/ui/init.js index 735a367bb..91b078f06 100644 --- a/js/ui/init.js +++ b/js/ui/init.js @@ -8,13 +8,12 @@ import {formatError} from '../misc/errorUtils.js'; // GJS finishes resolving this module. imports._promiseNative.setMainLoopHook(() => { // Queue starting the shell - GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { import('./main.js').then(main => main.start()).catch(e => { const error = new GLib.Error( Gio.IOErrorEnum, Gio.IOErrorEnum.FAILED, formatError(e)); global.context.terminate_with_error(error); }); - return GLib.SOURCE_REMOVE; }); // Run the meta context's main loop diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index d3d7ef8be..644409e35 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -282,7 +282,7 @@ const Key = GObject.registerClass({ _press(button) { if (button === this.keyButton) { - this._pressTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, + this._pressTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, KEY_LONG_PRESS_TIME, () => { this._pressTimeoutId = 0; @@ -296,8 +296,6 @@ const Key = GObject.registerClass({ this.keyButton.fake_release(); this._showSubkeys(); } - - return GLib.SOURCE_REMOVE; }); } @@ -1379,10 +1377,9 @@ export const Keyboard = GObject.registerClass({ } if (!this._showIdleId) { - this._showIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => { + this._showIdleId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT_IDLE, () => { this.open(Main.layoutManager.focusIndex); this._showIdleId = 0; - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._showIdleId, '[gnome-shell] this.open'); } @@ -1716,12 +1713,11 @@ export const Keyboard = GObject.registerClass({ return; } - this._keyboardRestingId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, + this._keyboardRestingId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, KEYBOARD_REST_TIME, () => { this._clearKeyboardRestTimer(); this._open(); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._keyboardRestingId, '[gnome-shell] this._clearKeyboardRestTimer'); } @@ -1751,12 +1747,11 @@ export const Keyboard = GObject.registerClass({ return; } - this._keyboardRestingId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, + this._keyboardRestingId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, KEYBOARD_REST_TIME, () => { this._clearKeyboardRestTimer(); this._close(); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._keyboardRestingId, '[gnome-shell] this._clearKeyboardRestTimer'); } @@ -2186,10 +2181,9 @@ class KeyboardController extends Signals.EventEmitter { this._surroundingUpdateTimeoutId = 0; } this._surroundingUpdateTimeoutId = - GLib.timeout_add(GLib.PRIORITY_DEFAULT, KEY_RELEASE_TIMEOUT, () => { + GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, KEY_RELEASE_TIMEOUT, () => { func(text, cursor, cursor); this._surroundingUpdateTimeoutId = 0; - return GLib.SOURCE_REMOVE; }); } }); diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 02cda39fd..41f4940f5 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -1379,10 +1379,9 @@ class LookingGlass extends St.BoxLayout { gcButton.connect('clicked', () => { gcButton.child.icon_name = 'user-trash-symbolic'; System.gc(); - this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => { + this._timeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 500, () => { gcButton.child.icon_name = 'user-trash-full-symbolic'; this._timeoutId = 0; - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id( this._timeoutId, diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js index 6e2c74aa9..4536436c1 100644 --- a/js/ui/magnifier.js +++ b/js/ui/magnifier.js @@ -1321,7 +1321,7 @@ class ZoomRegion { this._updateMousePosition(); this._clearScrollContentsTimer(); - this._scrollContentsTimerId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, POINTER_REST_TIME, () => { + this._scrollContentsTimerId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, POINTER_REST_TIME, () => { this._followingCursor = false; if (this._xDelayed != null && this._yDelayed != null) { this._scrollContentsToDelayed(this._xDelayed, this._yDelayed); @@ -1330,8 +1330,6 @@ class ZoomRegion { } this._scrollContentsTimerId = 0; - - return GLib.SOURCE_REMOVE; }); // Determine whether the system mouse pointer is over this zoom region. diff --git a/js/ui/main.js b/js/ui/main.js index 90e78a197..1b917f988 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -311,10 +311,9 @@ async function _initializeUI() { endSessionDialog = new EndSessionDialog.EndSessionDialog(); // We're ready for the session manager to move to the next phase - GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { Shell.util_sd_notify(); global.context.notify_ready(); - return GLib.SOURCE_REMOVE; }); _startDate = new Date(); @@ -998,10 +997,9 @@ export function queueDeferredWork(workId) { if (data.actor.mapped) { _queueBeforeRedraw(workId); } else if (_deferredTimeoutId === 0) { - _deferredTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, DEFERRED_TIMEOUT_SECONDS, () => { + _deferredTimeoutId = GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, DEFERRED_TIMEOUT_SECONDS, () => { _runAllDeferredWork(); _deferredTimeoutId = 0; - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(_deferredTimeoutId, '[gnome-shell] _runAllDeferredWork'); } diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index bf8725f16..d4f7cded8 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -366,10 +366,9 @@ export class Notification extends GObject.Object { delete this._updateDatetimeId; } else if (!this._updateDatetimeId) { this._updateDatetimeId = - GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { delete this._updateDatetimeId; this.datetime = GLib.DateTime.new_now_local(); - return GLib.SOURCE_REMOVE; }); } }); @@ -993,7 +992,7 @@ export const MessageTray = GObject.registerClass({ // We wait for a longer period if the notification popped up where the mouse pointer was already positioned. // That gives the user more time to mouse away from the notification and mouse back in in order to expand it. const timeout = this._useLongerNotificationLeftTimeout ? LONGER_HIDE_TIMEOUT : HIDE_TIMEOUT; - this._notificationLeftTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, timeout, this._onNotificationLeftTimeout.bind(this)); + this._notificationLeftTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, timeout, this._onNotificationLeftTimeout.bind(this)); GLib.Source.set_name_by_id(this._notificationLeftTimeoutId, '[gnome-shell] this._onNotificationLeftTimeout'); } } @@ -1022,7 +1021,7 @@ export const MessageTray = GObject.registerClass({ x < this._notificationLeftMouseX + MOUSE_LEFT_ACTOR_THRESHOLD && x > this._notificationLeftMouseX - MOUSE_LEFT_ACTOR_THRESHOLD) { this._notificationLeftMouseX = -1; - this._notificationLeftTimeoutId = GLib.timeout_add( + this._notificationLeftTimeoutId = GLib.timeout_add_once( GLib.PRIORITY_DEFAULT, LONGER_HIDE_TIMEOUT, this._onNotificationLeftTimeout.bind(this)); @@ -1034,7 +1033,6 @@ export const MessageTray = GObject.registerClass({ this._updateNotificationTimeout(0); this._updateState(); } - return GLib.SOURCE_REMOVE; } // All of the logic for what happens when occurs here; the various @@ -1208,7 +1206,7 @@ export const MessageTray = GObject.registerClass({ } if (timeout > 0) { this._notificationTimeoutId = - GLib.timeout_add(GLib.PRIORITY_DEFAULT, timeout, + GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, timeout, this._notificationTimeout.bind(this)); GLib.Source.set_name_by_id(this._notificationTimeoutId, '[gnome-shell] this._notificationTimeout'); } @@ -1235,7 +1233,6 @@ export const MessageTray = GObject.registerClass({ this._lastSeenMouseX = x; this._lastSeenMouseY = y; - return GLib.SOURCE_REMOVE; } _hideNotification(animate) { diff --git a/js/ui/osdWindow.js b/js/ui/osdWindow.js index e1f8d85fc..47c840a08 100644 --- a/js/ui/osdWindow.js +++ b/js/ui/osdWindow.js @@ -106,7 +106,7 @@ class OsdWindow extends Clutter.Actor { if (this._hideTimeoutId) GLib.source_remove(this._hideTimeoutId); - this._hideTimeoutId = GLib.timeout_add( + this._hideTimeoutId = GLib.timeout_add_once( GLib.PRIORITY_DEFAULT, HIDE_TIMEOUT, this._hide.bind(this)); GLib.Source.set_name_by_id(this._hideTimeoutId, '[gnome-shell] this._hide'); } @@ -130,7 +130,6 @@ class OsdWindow extends Clutter.Actor { global.compositor.enable_unredirect(); }, }); - return GLib.SOURCE_REMOVE; } _reset() { diff --git a/js/ui/overview.js b/js/ui/overview.js index 82f83f922..d3d64ae71 100644 --- a/js/ui/overview.js +++ b/js/ui/overview.js @@ -309,7 +309,7 @@ export class Overview extends Signals.EventEmitter { if (targetIsWindow) { this._lastHoveredWindow = dragEvent.targetActor._delegate.metaWindow; - this._windowSwitchTimeoutId = GLib.timeout_add( + this._windowSwitchTimeoutId = GLib.timeout_add_once( GLib.PRIORITY_DEFAULT, DND_WINDOW_SWITCH_TIMEOUT, () => { @@ -318,7 +318,6 @@ export class Overview extends Signals.EventEmitter { this._windowSwitchTimestamp); this.hide(); this._lastHoveredWindow = null; - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._windowSwitchTimeoutId, '[gnome-shell] Main.activateWindow'); } diff --git a/js/ui/panel.js b/js/ui/panel.js index d836107a8..e1d2b8bc5 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -233,7 +233,7 @@ class ActivitiesButton extends PanelMenu.Button { if (this._xdndTimeOut !== 0) GLib.source_remove(this._xdndTimeOut); - this._xdndTimeOut = GLib.timeout_add(GLib.PRIORITY_DEFAULT, BUTTON_DND_ACTIVATION_TIMEOUT, () => { + this._xdndTimeOut = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, BUTTON_DND_ACTIVATION_TIMEOUT, () => { this._xdndToggleOverview(); }); GLib.Source.set_name_by_id(this._xdndTimeOut, '[gnome-shell] this._xdndToggleOverview'); @@ -266,7 +266,6 @@ class ActivitiesButton extends PanelMenu.Button { GLib.source_remove(this._xdndTimeOut); this._xdndTimeOut = 0; - return GLib.SOURCE_REMOVE; } }); diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 9af1f791a..515dc8279 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -261,13 +261,12 @@ export class ScreenShield extends Signals.EventEmitter { const lockTimeout = Math.max( adjustAnimationTime(STANDARD_FADE_TIME), this._settings.get_uint(LOCK_DELAY_KEY) * 1000); - this._lockTimeoutId = GLib.timeout_add( + this._lockTimeoutId = GLib.timeout_add_once( GLib.PRIORITY_DEFAULT, lockTimeout, () => { this._lockTimeoutId = 0; this.lock(false); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._lockTimeoutId, '[gnome-shell] this.lock'); } @@ -480,9 +479,8 @@ export class ScreenShield extends Signals.EventEmitter { if (params.fadeToBlack && params.animateFade) { // Take a beat - const id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, MANUAL_FADE_TIME, () => { + const id = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, MANUAL_FADE_TIME, () => { this._activateFade(this._shortLightbox, MANUAL_FADE_TIME); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(id, '[gnome-shell] this._activateFade'); } else { diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index b1e5e58f7..e0ec8b76a 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -94,7 +94,7 @@ class Tooltip extends St.Label { if (this._timeoutId) return; - this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 300, () => { + this._timeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 300, () => { this.opacity = 0; this.show(); @@ -117,7 +117,6 @@ class Tooltip extends St.Label { }); this._timeoutId = null; - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] tooltip.open'); } @@ -2836,9 +2835,8 @@ class SelectArea extends St.Widget { try { await this._grabHelper.grabAsync({actor: this}); } finally { - GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { this.destroy(); - return GLib.SOURCE_REMOVE; }); } @@ -3083,9 +3081,8 @@ class PickPixel extends St.Widget { } finally { this._previewCursor.destroy(); - GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { this.destroy(); - return GLib.SOURCE_REMOVE; }); } diff --git a/js/ui/scripting.js b/js/ui/scripting.js index d47354c0b..ea14d526c 100644 --- a/js/ui/scripting.js +++ b/js/ui/scripting.js @@ -37,9 +37,8 @@ import {loadInterfaceXML} from '../misc/fileUtils.js'; */ export function sleep(milliseconds) { return new Promise(resolve => { - const id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, milliseconds, () => { + const id = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, milliseconds, () => { resolve(); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(id, '[gnome-shell] sleep'); }); diff --git a/js/ui/search.js b/js/ui/search.js index 3c171b43f..897bae5b9 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -727,7 +727,6 @@ export const SearchResultsView = GObject.registerClass({ _onSearchTimeout() { this._searchTimeoutId = 0; this._doSearch(); - return GLib.SOURCE_REMOVE; } setTerms(terms) { @@ -759,7 +758,7 @@ export const SearchResultsView = GObject.registerClass({ this._updateSearchProgress(); if (this._searchTimeoutId === 0) - this._searchTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, this._onSearchTimeout.bind(this)); + this._searchTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 150, this._onSearchTimeout.bind(this)); this._highlighter = new Highlighter(this._terms); diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js index c098a41e1..774796369 100644 --- a/js/ui/status/accessibility.js +++ b/js/ui/status/accessibility.js @@ -94,15 +94,13 @@ class ATIndicator extends PanelMenu.Button { const items = this.menu._getMenuItems(); this.visible = alwaysShow || items.some(f => !!f.state); - - return GLib.SOURCE_REMOVE; } _queueSyncMenuVisibility() { if (this._syncMenuVisibilityIdle) return; - this._syncMenuVisibilityIdle = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._syncMenuVisibility.bind(this)); + this._syncMenuVisibilityIdle = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, this._syncMenuVisibility.bind(this)); GLib.Source.set_name_by_id(this._syncMenuVisibilityIdle, '[gnome-shell] this._syncMenuVisibility'); } diff --git a/js/ui/status/backgroundApps.js b/js/ui/status/backgroundApps.js index 3399b9f9e..aff6d6f52 100644 --- a/js/ui/status/backgroundApps.js +++ b/js/ui/status/backgroundApps.js @@ -113,12 +113,11 @@ const BackgroundAppMenuItem = GObject.registerClass({ async _quitApp() { this._spinner.play(); this._spinnerTimeoutId = - GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, SPINNER_TIMEOUT, + GLib.timeout_add_seconds_once(GLib.PRIORITY_DEFAULT, SPINNER_TIMEOUT, () => { // Assume the quit request has failed, stop the spinner this._spinner.stop(); delete this._spinnerTimeoutId; - return GLib.SOURCE_REMOVE; }); try { diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index b8a5ea1d4..a9cd1437b 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -176,10 +176,9 @@ const BtClient = GObject.registerClass({ _queueDevicesChanged() { if (this._devicesChangedId) return; - this._devicesChangedId = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + this._devicesChangedId = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { delete this._devicesChangedId; this.emit('devices-changed'); - return GLib.SOURCE_REMOVE; }); } diff --git a/js/ui/status/remoteAccess.js b/js/ui/status/remoteAccess.js index 7974a1b06..3bcdcbb88 100644 --- a/js/ui/status/remoteAccess.js +++ b/js/ui/status/remoteAccess.js @@ -187,7 +187,6 @@ export const ScreenSharingIndicator = GObject.registerClass({ _hideIndicator() { this.hide(); delete this._hideIndicatorId; - return GLib.SOURCE_REMOVE; } _sync() { @@ -210,7 +209,7 @@ export const ScreenSharingIndicator = GObject.registerClass({ const timeUntilHideUs = MIN_SHARED_INDICATOR_VISIBLE_TIME_US - timeSinceVisibleUs; this._hideIndicatorId = - GLib.timeout_add(GLib.PRIORITY_DEFAULT, + GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, timeUntilHideUs / GLib.TIME_SPAN_MILLISECOND, () => this._hideIndicator()); } diff --git a/js/ui/status/thunderbolt.js b/js/ui/status/thunderbolt.js index c9b42089c..0fe877657 100644 --- a/js/ui/status/thunderbolt.js +++ b/js/ui/status/thunderbolt.js @@ -181,7 +181,7 @@ class AuthRobot extends Signals.EventEmitter { return; this._enrolling = true; - GLib.idle_add(GLib.PRIORITY_DEFAULT, + GLib.idle_add_once(GLib.PRIORITY_DEFAULT, this._enrollDevicesIdle.bind(this)); } @@ -190,7 +190,7 @@ class AuthRobot extends Signals.EventEmitter { const dev = devices.shift(); if (dev === undefined) - return GLib.SOURCE_REMOVE; + return; try { await this._client.enrollDevice(dev.Uid, Policy.DEFAULT); @@ -202,13 +202,12 @@ class AuthRobot extends Signals.EventEmitter { this._enrolling = this._devicesToEnroll.length > 0; if (this._enrolling) { - GLib.idle_add(GLib.PRIORITY_DEFAULT, + GLib.idle_add_once(GLib.PRIORITY_DEFAULT, this._enrollDevicesIdle.bind(this)); } } catch (error) { this.emit('enroll-failed', null, error); } - return GLib.SOURCE_REMOVE; } } diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js index 4f57ebb3a..0dbb2cefe 100644 --- a/js/ui/status/volume.js +++ b/js/ui/status/volume.js @@ -194,10 +194,9 @@ const StreamSlider = GObject.registerClass({ const volumeChanged = this._stream.volume !== prevVolume; if (volumeChanged && !this._notifyVolumeChangeId && !this._inDrag) { - this._notifyVolumeChangeId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 30, () => { + this._notifyVolumeChangeId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, 30, () => { this._notifyVolumeChange(); this._notifyVolumeChangeId = 0; - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._notifyVolumeChangeId, '[gnome-shell] this._notifyVolumeChangeId'); diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js index b4cb9d57f..2cd5ab7ed 100644 --- a/js/ui/switcherPopup.js +++ b/js/ui/switcherPopup.js @@ -158,12 +158,11 @@ export const SwitcherPopup = GObject.registerClass({ // We delay showing the popup so that fast Alt+Tab users aren't // disturbed by the popup briefly flashing. - this._initialDelayTimeoutId = GLib.timeout_add( + this._initialDelayTimeoutId = GLib.timeout_add_once( GLib.PRIORITY_DEFAULT, POPUP_DELAY_TIMEOUT, () => { this._showImmediately(); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(this._initialDelayTimeoutId, '[gnome-shell] Main.osdWindow.cancel'); return true; @@ -294,14 +293,13 @@ export const SwitcherPopup = GObject.registerClass({ if (this._motionTimeoutId !== 0) GLib.source_remove(this._motionTimeoutId); - this._motionTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, DISABLE_HOVER_TIMEOUT, this._mouseTimedOut.bind(this)); + this._motionTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, DISABLE_HOVER_TIMEOUT, this._mouseTimedOut.bind(this)); GLib.Source.set_name_by_id(this._motionTimeoutId, '[gnome-shell] this._mouseTimedOut'); } _mouseTimedOut() { this._motionTimeoutId = 0; this.mouseActive = true; - return GLib.SOURCE_REMOVE; } _isActorOutside(actor) { @@ -312,13 +310,12 @@ export const SwitcherPopup = GObject.registerClass({ if (this._noModsTimeoutId !== 0) GLib.source_remove(this._noModsTimeoutId); - this._noModsTimeoutId = GLib.timeout_add( + this._noModsTimeoutId = GLib.timeout_add_once( GLib.PRIORITY_DEFAULT, NO_MODS_TIMEOUT, () => { this._finish(global.display.get_current_time_roundtrip()); this._noModsTimeoutId = 0; - return GLib.SOURCE_REMOVE; }); } diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js index fdd79705c..92d6cf8aa 100644 --- a/js/ui/windowManager.js +++ b/js/ui/windowManager.js @@ -297,10 +297,9 @@ class WorkspaceTracker { if (workspace._keepAliveId) GLib.source_remove(workspace._keepAliveId); - workspace._keepAliveId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, duration, () => { + workspace._keepAliveId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, duration, () => { workspace._keepAliveId = 0; this._queueCheckWorkspaces(); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(workspace._keepAliveId, '[gnome-shell] this._queueCheckWorkspaces'); } @@ -308,12 +307,11 @@ class WorkspaceTracker { _windowRemoved(workspace, window) { workspace._lastRemovedWindow = window; this._queueCheckWorkspaces(); - const id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, LAST_WINDOW_GRACE_TIME, () => { + const id = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, LAST_WINDOW_GRACE_TIME, () => { if (workspace._lastRemovedWindow === window) { workspace._lastRemovedWindow = null; this._queueCheckWorkspaces(); } - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(id, '[gnome-shell] this._queueCheckWorkspaces'); } @@ -1890,10 +1888,9 @@ export class WindowManager { this.actionMoveWorkspace(ws); this._canScroll = false; - GLib.timeout_add(GLib.PRIORITY_DEFAULT, + GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, SCROLL_TIMEOUT_TIME, () => { this._canScroll = true; - return GLib.SOURCE_REMOVE; }); return Clutter.EVENT_STOP; diff --git a/js/ui/workspace.js b/js/ui/workspace.js index ccd23ae6b..5c043e4be 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -1188,11 +1188,10 @@ class Workspace extends St.Widget { if (!win) { // Newly-created windows are added to a workspace before // the compositor finds out about them... - const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { if (metaWin.get_compositor_private() && metaWin.get_workspace() === this.metaWorkspace) this._doAddWindow(metaWin); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(id, '[gnome-shell] this._doAddWindow'); return; diff --git a/js/ui/workspaceSwitcherPopup.js b/js/ui/workspaceSwitcherPopup.js index 20313558a..9e65d3974 100644 --- a/js/ui/workspaceSwitcherPopup.js +++ b/js/ui/workspaceSwitcherPopup.js @@ -85,7 +85,7 @@ class WorkspaceSwitcherPopup extends Clutter.Actor { if (this._timeoutId !== 0) GLib.source_remove(this._timeoutId); - this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, DISPLAY_TIMEOUT, this._onTimeout.bind(this)); + this._timeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, DISPLAY_TIMEOUT, this._onTimeout.bind(this)); GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] this._onTimeout'); this._redisplayAllPopups(); @@ -101,7 +101,6 @@ class WorkspaceSwitcherPopup extends Clutter.Actor { } _onTimeout() { - GLib.source_remove(this._timeoutId); this._timeoutId = 0; this.ease({ opacity: 0.0, @@ -109,7 +108,6 @@ class WorkspaceSwitcherPopup extends Clutter.Actor { mode: Clutter.AnimationMode.EASE_OUT_QUAD, onComplete: () => this.destroy(), }); - return GLib.SOURCE_REMOVE; } _onDestroy() { diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js index 40ac36307..79892f0f1 100644 --- a/js/ui/workspaceThumbnail.js +++ b/js/ui/workspaceThumbnail.js @@ -360,12 +360,11 @@ export const WorkspaceThumbnail = GObject.registerClass({ if (!win) { // Newly-created windows are added to a workspace before // the compositor finds out about them... - const id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + const id = GLib.idle_add_once(GLib.PRIORITY_DEFAULT, () => { if (!this._removed && metaWin.get_compositor_private() && metaWin.get_workspace() === this.metaWorkspace) this._doAddWindow(metaWin); - return GLib.SOURCE_REMOVE; }); GLib.Source.set_name_by_id(id, '[gnome-shell] this._doAddWindow'); return;